package com.haidechizi.leetcode;

/**
 * @author: wangdejun
 * @create: 2020-04-02 10:57
 **/
public class _3_数组中重复的数字 {
    public int findRepeatNumber(int[] nums) {
        for(int i = 0; i < nums.length;i++) {
            while (i != nums[i]) {
                if(nums[i] == nums[nums[i]]) {
                    return nums[i];
                }
                swap(nums,i,nums[i]);
            }

        }
        return 0;
    }

    public void swap(int[] nums ,int i,int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

}
